

$('.hMenu ul > li').has('ul').addClass('with');
$('.hMenu ul > li.with').hover(function(){
	$(this).children('ul').stop(true).delay( 200 ).slideDown(0);
	$('.fake-menu').stop(true).slideDown();
	$('.colored-sections').stop(true).animate({
		marginTop : 45
	});
},function(){
	$(this).children('ul').stop(true).slideUp(10);
	$('.fake-menu').stop(true).slideUp();
	$('.colored-sections').stop(true).animate({
		marginTop : 0
	});
});



/******************************
 * body sizing
 ******************************/

function sizing() {
    pageWidth = $(window).width();
    if (pageWidth < 1024) {
        $('.container').css('width', '990px');
    }
    else {
        $('.container').css('width', '1080px');
    }
}

$(window).resize(function() {
    sizing();
});

/******************************
 * News Ticker
 ******************************/

var dd = $('.news-list').easyTicker({
    direction: 'up',
    // easing: 'easeInOutBack',
    speed: 200,
    interval: 4000,
    height: 40,
    visible: 1,
    mousePause: 1,
}).data('easyTicker');

//  news ticker text split

$(".news-list li a").each(function(i) {
    len = $(this).text().length;
    if (len > 100)
    {
        $(this).text($(this).text().substr(0, 80) + ' ...');
    }
});

/******************************
 * Side Nav
 ******************************/

$(".left-col nav li").has("ul").addClass("with-sub");
$('.left-col nav li.with-sub > a').click(function() {
    $('.left-col nav li.with-sub').each(function(index, element) {
        $(this).children('.left-col nav li ul').slideUp();
    });
    $('.left-col nav li.with-sub > a').each(function(index, element) {
        $(this).parent('li').removeClass('open');
    });

    if (($(this).next('ul').css('display') == 'none')) {
        $(this).next('ul').slideToggle(300);
        $(this).parent('li').addClass('open');
    }
});

$('.toggle-show').click(function() {
    $this = $(this);
    $this.parent('h3').next('.hidden-box').toggle();
    $this.toggleClass('open');

});
/******************************
 * Comments
 ******************************/
// Drag for Sort

// attachment options
$('.attach').click(function() {
    $('.attach-option').toggle();
    $('.timeline .gray-box').hide();
});

$('.comment-count').click(function() {
    $(this).parent('.details').next('.comments').toggle();
});
/******************************
 * Tabs
 ******************************/
$(".tab-content:first").show();
i = 1;
l = 1;
$(".tab-content").each(function() {
    $(this).addClass('cont' + l);
    l++;
});

$('ul.tabs li').each(function() {
    $(this).addClass("tab" + i);

    i++;
    
    $(this).click(function() {
        var tabId = $(this).attr('class');
        window.location.hash = tabId;
		$(this).siblings('li:first').removeClass("firstAct");
        // tab switching 
        $('ul.tabs li').removeClass("active");
        $(this).addClass("active");
        $(".tab-content").hide();
        var activeTab = $(this).find("a").attr("href");
        $(activeTab).fadeIn();
        return false;
    });
});

$(function() {

    var tab = window.location.hash;
    var name = tab.substring(1, tab.length);
    
    $('ul.tabs li').removeClass("active");
    // $("." + name).addClass("active");
    $(".tab-content").hide();
    var activeTab = tab;
    $(activeTab).fadeIn();

});
if (window.location.hash !== "#tab1") {
	 $(".tabs li").removeClass('firstAct');
}
if (window.location.hash == false) {
	$(".tabs li:first").addClass('firstAct');
}
/******************************
 * privacy list
 ******************************/
$('.privacy-options').click(function() {
    $this = $(this);
    $this.children('ul').slideToggle(100);
    $this.children('span.privacy-arrow').toggleClass('opened');
});
$('.privacy-options ul li').click(function() {
    data = $(this).text();
    $(this).parent('ul').parent('.privacy-options').children('i').text(data);
});


$('.add-group a.red-title').click(function() {
    $(this).parent('.add-group').next('.gray-box').toggle();
    $(this).next('.form-list').toggle();
});


$('#add-student').click(function() {
    $(this).next('.addStudent').toggle();
});



$('.add-upload').click(function() {
    $(this).parent('li').clone(function() {
    }).appendTo('ul.attach-photo');
    $(this).remove();
});
$('.show-report').click(function() {
    $('.report').toggle();
});
/******************************
 * Full Calendar
 ******************************/
$('#manageCal').click(function() {
    $('.calendar-advanced').toggle();
});

$('.timeline a.settings').click(function() {
    $('.timeline .gray-box').toggle();
    $('.timeline .attach-option').hide();

});

$('.counter').click(function() {
    $(this).next('.users').slideToggle();
    $(this).toggleClass('current');
});

/******************************
 * popup
 ******************************/
winWidth = $(window).width();

$('.popup').css('left', (winWidth - 470) / 2);
$('.popup.profile-popup').css('left', (winWidth - 590) / 2);

/*function popHieght() {
 winHieght = $(window).height();
 popupHeight = $('.popup').height()+94;
 if (popupHeight > winHieght) {
 $('.popup-content').css('height', winHieght-154);
 }
 else {
 
 if ($('.popup-content').height() < 365) {
 $('.popup-content').css('height', winHieght-154);	
 }
 }
 }*/
$('.change-password').click(function() {
    $('.change-pass, .overlay').fadeIn();
});
$('.show-popup').click(function() {
    $('.popup, .overlay').fadeIn(300);
    $('body').addClass('body-fix');
    /*popHieght();
     $(window).resize(function(){
     popHieght();	
     });*/

});

$('.popup-close, .overlay').click(function() {
    $('.popup, .overlay').fadeOut(300);
    $('body').removeClass('body-fix');
});
$(".tree li").has("ul").addClass("with-sub");

$('.tree li > a').click(function(e) {
    $(this).next('ul').slideToggle(300);
    $(this).parent('li').toggleClass('open');
});
$('.closeAll').click(function() {
    $('.tree li ul').slideUp(300);
    $('.tree li.with-sub').removeClass('open')
});

$(window).load(function() {
    // $('.switch input[type=checkbox]').prop('checked', false);	
});

$(".switch span").click(function() {
    $(this).toggleClass('checked');
    $(this).next('input[type=checkbox]').trigger('click');
});
$(".switch li").each(function(index, element) {
    if ($(this).children('input[type=checkbox]').is(':checked')) {
        $(this).children('span').addClass('checked');
    }
});

$('.reset').click(function() {
    $('.switch input[type=checkbox]').prop('checked', false);
    $(".switch span").removeClass('checked');
});

$('#show-youtube').click(function() {
    $('.upload-input').toggle();
    $('.attach-option input[type=text]').toggle();
});

$('.stuff-attachments').click(function() {
    $('.stuff-attach-panel').toggle();
});

$('.notifications').click(function(){
	$('.notifications-pop').show();
	$('.overlay').show();
});

$('.home-table tr:even td').addClass('highlighted');

$('.links a span').click(function(){
	$(this).parent('a').remove();
});